const baseurl = 'https://api-hmugo-web.itheima.net/api';

function http(params) {
  wx.showLoading({
    title: '加载中',
  });
  return new Promise((resolve, reject) => {
    wx.request({
      ...params,
      url: baseurl + params.url,
      success(res) {
        console.log(res);
        let { status } = res.data.meta;
        if (status == 200) {
          resolve(res.data);
        }
      },
      fail(err) {
        reject(err);
      },
      complete() {
        wx.hideLoading();
      },
    });
  });
}
export default http;
